package com.exp.bookhouse.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.exp.bookhouse.pojo.SysLog;
import com.exp.bookhouse.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Api(value = "系统日志管理接口", tags = "管理员管理日志操作")
@RequestMapping("/admin")
@Controller
public class SysLogControllerAdmin {

    @Autowired
    private SysLogService sysLogService;


    @ApiOperation(value = "分页查询日志信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "p", value = "页数", required = false, dataType = "Int"),
            @ApiImplicitParam(paramType = "query", name = "s", value = "显示记录数", required = false, dataType = "Int"),
    })
    @GetMapping("/toSysLog")
    public String toSysLog(@RequestParam(value = "p",required = false,defaultValue = "1")Integer page,
                         @RequestParam(value = "s",required = false,defaultValue ="5")Integer size,
                         Model model){
        IPage<SysLog> iPage =  sysLogService.querySysLogByPage(page,size);
        List<SysLog> Ipage = iPage.getRecords();
        model.addAttribute("iPage",iPage);
        return "sysLog";
    }

}
